package cn.stazxr.component;

import javax.swing.*;
import java.awt.*;

/**
 * Package: cn.stazxr.component
 * ClassName: TextFieldTest
 *
 * @Author: stazxr
 * @Create: 2023/12/2
 * @Version: v1.0
 **/
public class TextFieldTest {
    public static void main(String[] args) {
        Frame frame = new Frame("Hello world!");
        frame.setBounds(500, 300, 500, 300);
        frame.setFont(new Font("Microsoft YaHei UI", Font.ITALIC, 15));
        frame.setLayout(null);

        TextField textField = new TextField();
        textField.setBounds(50, 50, 300, 30);
        textField.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 15));
        textField.setEchoChar('*');
        frame.add(textField);

        JButton button = new JButton("点击提交");
        button.setBounds(360, 50, 100, 30);
        frame.add(button);
        button.addActionListener(e -> {
            System.out.println(textField.getText());
            textField.setText("");
        });

        frame.setVisible(true);
    }
}
